<?php

use Illuminate\Http\Request;

Route::namespace('Api')->prefix('v1')->middleware('cors')->group(function () {
  Route::namespace('Web')->middleware('api.guard')->group(function () {
    // 上传文件-七牛
    // Route::post('/uploadFile', 'CommonController@uploadFile')->name('users.uploadFile');
    // 上传文件-本地
    Route::post('/uploadFileV1', 'CommonController@uploadFileV1')->name('users.uploadFileV1');
    Route::middleware('api.refresh')->group(function () {
      //当前用户信息
      Route::get('/users/info', 'UserController@info')->name('users.info');
    });
    // 轮播图
    Route::get('/picture', 'CommonController@pictureList')->name('topics.picture');
    // 分类
    Route::get('/treeCate', 'CommonController@treeList')->name('topics.cate');
    // 内容列表
    Route::get('/topic', 'TopicController@index')->name('topics.topicList');
    // 内容详情
    Route::get('/topic/{id}', 'TopicController@detail')->name('topics.detail');
    // 验证码
    Route::get('/captcha', 'CommonController@createCaptha')->name('common.captcha');
    // 站点配置信息
    Route::get('/siteInfo/{code}', 'CommonController@configInfoByCode')->name('topics.siteInfo');
  });

  Route::namespace('Admin')->middleware('admin.guard')->group(function () {
    // 管理员登录
    Route::post('/admins/login', 'AdminController@login')->name('admins.login');
    Route::middleware('admin.refresh')->group(function () {
      //管理员退出
      Route::get('/admins/logout', 'AdminController@logout')->name('admins.logout');
      // 管理员列表
      Route::get('/admins/admin', 'AdminController@index')->name('admins.adminList');
      // 管理员详情
      Route::get('/admins/admin/{id}', 'AdminController@show')->name('admins.adminDetail');
      // 管理员详情-名称搜索
      Route::get('/admins/adminInfo', 'AdminController@detail')->name('admins.adminInfo');
      // 新增管理员
      Route::post('/admins/admin', 'AdminController@store')->name('admins.adminAdd');
      // 修改管理员
      Route::put('/admins/admin', 'AdminController@update')->name('admins.adminUpdate');
      // 删除管理员
      Route::delete('/admins/admin/{id}', 'AdminController@delete')->name('admins.adminDelete');

      // 内容列表
      Route::get('/admins/topic', 'TopicController@index')->name('admins.topicList');
      // 内容详情
      Route::get('/admins/topic/{id}', 'TopicController@detail')->name('admins.topicDetail');
      // 新增内容
      Route::post('/admins/topic', 'TopicController@add')->name('admins.topicAdd');
      // 修改内容
      Route::put('/admins/topic', 'TopicController@update')->name('admins.topicUpdate');
      // 删除内容
      Route::delete('/admins/topic/{id}', 'TopicController@delete')->name('admins.topicDelete');

      // 轮播图列表
      Route::get('/admins/picture', 'PictureController@index')->name('admins.pictureList');
      // 轮播图详情
      Route::get('/admins/picture/{id}', 'PictureController@detail')->name('admins.pictureDetail');
      // 新增轮播图
      Route::post('/admins/picture', 'PictureController@add')->name('admins.pictureAdd');
      // 修改轮播图
      Route::put('/admins/picture', 'PictureController@update')->name('admins.pictureUpdate');
      // 删除轮播图
      Route::delete('/admins/picture/{id}', 'PictureController@delete')->name('admins.pictureDelete');

      // 文件列表
      Route::get('/admins/filelist', 'FilelistController@index')->name('admins.filelistList');
      // 文件详情
      Route::get('/admins/filelist/{id}', 'FilelistController@detail')->name('admins.filelistDetail');
      // 新增文件
      Route::post('/admins/filelist', 'FilelistController@add')->name('admins.filelistAdd');
      // 修改文件
      Route::put('/admins/filelist', 'FilelistController@update')->name('admins.filelistUpdate');
      // 删除文件
      Route::delete('/admins/filelist/{id}', 'FilelistController@delete')->name('admins.filelistDelete');

      // 分类列表
      Route::get('/admins/cate', 'CateController@index')->name('admins.cateList');
      // 树形列表
      Route::get('/admins/treeList', 'CateController@treeList')->name('admins.treeList');
      // 分类详情
      Route::get('/admins/cate/{id}', 'CateController@detail')->name('admins.cateDetail');
      // 新增分类
      Route::post('/admins/cate', 'CateController@add')->name('admins.cateAdd');
      // 修改分类
      Route::put('/admins/cate', 'CateController@update')->name('admins.cateUpdate');
      // 删除分类
      Route::delete('/admins/cate/{id}', 'CateController@delete')->name('admins.cateDelete');

      // 配置列表
      Route::get('/admins/config', 'ConfigController@index')->name('admins.configList');
      // 配置详情
      Route::get('/admins/config/{id}', 'ConfigController@detail')->name('admins.configDetail');
      // 配置详情(code搜索)
      Route::get('/admins/configByCode/{code}', 'ConfigController@detailByCode')->name('admins.configCodeDetail');
      // 新增配置
      Route::post('/admins/config', 'ConfigConfigController@add')->name('admins.configAdd');
      // 修改配置
      Route::put('/admins/config', 'ConfigController@update')->name('admins.configUpdate');
      // 删除配置
      Route::delete('/admins/config/{id}', 'ConfigController@delete')->name('admins.configDelete');

      // 角色列表
      Route::get('/admins/role', 'RoleController@index')->name('admins.roleList');
      // 角色详情
      Route::get('/admins/role/{id}', 'RoleController@detail')->name('admins.roleDetail');
      // 新增角色
      Route::post('/admins/role', 'RoleController@add')->name('admins.roleAdd');
      // 修改角色
      Route::put('/admins/role', 'RoleController@update')->name('admins.roleUpdate');
      // 删除角色
      Route::delete('/admins/role/{id}', 'RoleController@delete')->name('admins.roleDelete');

      // 菜单列表
      Route::get('/admins/menu', 'MenuController@index')->name('admins.menuList');
      // 菜单详情
      Route::get('/admins/menu/{id}', 'MenuController@detail')->name('admins.menuDetail');
      // 新增菜单
      Route::post('/admins/menu', 'MenuController@add')->name('admins.menuAdd');
      // 修改菜单
      Route::put('/admins/menu', 'MenuController@update')->name('admins.menuUpdate');
      // 删除菜单
      Route::delete('/admins/menu/{id}', 'MenuController@delete')->name('admins.menuDelete');
    });
  });
});
